﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Shell;
using EnvDTE;
using System.ComponentModel.Design;

namespace ResourceViewerExtension
{
    [Guid("17938190-9351-4a31-a9bc-d41f7d35bfdf")]
    public class ResourceViewerWindow : ToolWindowPane
    {
        public ResourceViewerWindow() :
            base(null)
        {
            this.ToolBar = new CommandID(GuidList.guidResourceViewerExtensionCmdSet, PkgCmdIDList.RVToolbar);
            this.ToolBarLocation = (int)VSTWT_LOCATION.VSTWT_TOP;
            // Set the window title reading it from the resources.
            this.Caption = Resources.Resources.ToolWindowTitle;
            // Set the image that will appear on the tab of the window frame
            this.BitmapResourceID = 301;

            base.Content = new MainView();
        }

        #region FilePath

        public string FilePath
        {
            set
            {
                MainViewModel.Instance.LoadFilePathCommand.Execute(value);
            }
        }

        #endregion

        public override void OnToolWindowCreated()
        {
            MainViewModel.Instance.ToolWindowCreatedCommand.Execute(this as IServiceProvider);

            base.OnToolWindowCreated();
        }

        protected override void OnClose()
        {
            MainViewModel.Instance.ViewUnLoadedCommand.Execute(null);

            base.OnClose();
        }

    }
}
